from django.db import models

from utils.models import TimeStampedModel


class City(TimeStampedModel):
    name = models.CharField(max_length=25, verbose_name='城市名')
    description = models.CharField(max_length=200, verbose_name='城市描述')

    class Meta:
        verbose_name = '城市'
        verbose_name_plural = verbose_name


class Organization(TimeStampedModel):
    name = models.CharField(max_length=50, verbose_name='机构名称')
    description = models.CharField(max_length=300, verbose_name='机构描述')
    clicks = models.IntegerField(default=0, verbose_name='点击数')
    collections = models.IntegerField(default=0, verbose_name='收藏数')
    cover = models.ImageField(upload_to='organization/%Y/%m', max_length=100, verbose_name='封面图')
    address = models.CharField(max_length=150, verbose_name='机构地址')
    city = models.ForeignKey(City, verbose_name='所在城市', on_delete=True)

    class Meta:
        verbose_name = '组织机构'
        verbose_name_plural = verbose_name


class Teacher(TimeStampedModel):
    organization = models.ForeignKey(Organization, verbose_name='所属机构', on_delete=True)
    name = models.CharField(max_length=25, verbose_name='教师名')
    working_years = models.IntegerField(default=0, verbose_name='工作年限')
    company = models.CharField(max_length=50, verbose_name='就职公司')
    position = models.CharField(max_length=50, verbose_name='职位')
    features = models.CharField(max_length=50, verbose_name='特色')
    clicks = models.IntegerField(default=0, verbose_name='点击数')
    collections = models.IntegerField(default=0, verbose_name='收藏数')

    class Meta:
        verbose_name = '教师'
        verbose_name_plural = verbose_name
